package com.lollipop.checkin.dto;

import com.lollipop.checkin.constant.CheckInConstant;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serializable;

/**
 * 签到响应DTO
 * 封装签到结果的响应数据
 */
@Data
public class CheckInResponse implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 状态码
     * {@link CheckInConstant#CHECKIN_SUCCESS}
     * {@link CheckInConstant#ALREADY_CHECKED_IN}
     * {@link CheckInConstant#CHECKIN_FAILED}
     */
    @Schema(description = "状态码（1-签到成功，2-今日已签到，3-签到失败）")
    private int code;

    /**
     * 消息
     */
    @Schema(description = "响应消息")
    private String message;

    /**
     * 签到日期（格式：yyyy-MM-dd）
     */
    @Schema(description = "签到日期（格式：yyyy-MM-dd）")
    private String checkInDate;

    /**
     * 连续签到天数
     */
    @Schema(description = "连续签到天数")
    private int continueDays;

    /**
     * 总签到天数
     */
    @Schema(description = "总签到天数")
    private int totalDays;

    /**
     * 是否为首次签到
     */
    @Schema(description = "是否为首次签到")
    private boolean firstCheckIn;

    /**
     * 签到活动的参与人数（如果有活动）
     */
    @Schema(description = "签到活动的参与人数（如果有活动）")
    private long activityParticipants;

    /**
     * 创建成功的响应
     *
     * @param checkInDate 签到日期
     * @param continueDays 连续签到天数
     * @param totalDays 总签到天数
     * @param firstCheckIn 是否为首次签到
     * @param activityParticipants 活动参与人数
     * @return 签到响应
     */
    public static CheckInResponse success(String checkInDate, int continueDays, int totalDays, boolean firstCheckIn, long activityParticipants) {
        CheckInResponse response = new CheckInResponse();
        response.setCode(CheckInConstant.CHECKIN_SUCCESS);
        response.setMessage("签到成功");
        response.setCheckInDate(checkInDate);
        response.setContinueDays(continueDays);
        response.setTotalDays(totalDays);
        response.setFirstCheckIn(firstCheckIn);
        response.setActivityParticipants(activityParticipants);
        return response;
    }

    /**
     * 创建已签到的响应
     *
     * @param checkInDate 签到日期
     * @return 签到响应
     */
    public static CheckInResponse alreadyCheckedIn(String checkInDate) {
        CheckInResponse response = new CheckInResponse();
        response.setCode(CheckInConstant.ALREADY_CHECKED_IN);
        response.setMessage("今日已签到");
        response.setCheckInDate(checkInDate);
        return response;
    }

    /**
     * 创建失败的响应
     *
     * @param message 失败消息
     * @return 签到响应
     */
    public static CheckInResponse failed(String message) {
        CheckInResponse response = new CheckInResponse();
        response.setCode(CheckInConstant.CHECKIN_FAILED);
        response.setMessage(message);
        return response;
    }
}